package com.tensquare.thirdpary.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.tensquare.thirdpary.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.print.attribute.HashAttributeSet;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/8/26-16:44
 * ------------------------------
 */
@RestController
@RequestMapping("/thirdpary/aliyun/oss")
public class OssController extends BaseController {
    @Autowired
    private OssService ossService;
    /**
     * 功能: 文件上传
     * 参数:
     * 返回值: java.lang.String
     * 时间: 2021/8/26 16:44
     */
    @PostMapping("/upload")
    public AjaxResult upload(MultipartFile file) throws IOException {
        String url = ossService.uploadLoad(file);
        System.out.println("url = " + url);
        Map map = new HashMap<>();
        map.put("url",url);
        AjaxResult ajaxResult = AjaxResult.success(map);
        return ajaxResult;
    }
}
